<template>
  <common-card title="今日销售额" :value="numberFormat(salesToday)">
    <template #default>
      <div class="compare">
        <div>日同比 &nbsp;{{salesGrowthLastDay}}% &nbsp;<span class="decrement"></span></div>
        <div>月同比 &nbsp;{{salesGrowthLastMonth}}% &nbsp;<span class="increment"></span></div>
      </div>
    </template>
    <template #footer>
      <div>昨日销售额<span class="emphasis">{{moneyFormat(salesLastDay)}}</span></div>
    </template>
  </common-card>
</template>

<script lang ='ts'>
// 引入仓库pinna
import {useReportDataStore} from '@/stores/reportData'
import CommonCard from "./CommonCard.vue";
import useFormat from "@/hooks/useFormat"
import { computed } from '@vue/runtime-core';
const {numberFormat,moneyFormat} = useFormat()
export default {
  name: "TodaySales",
  components: { CommonCard },
};
</script>
<script lang='ts' setup>
  // 获取store实例
  const reportDataStore = useReportDataStore()
// 使用计算属性获取展示的数据
//   salesGrowthLastDay:-19.16
// salesGrowthLastMonth:56.67
// salesLastDay:36000000
  const salesToday=computed(()=> reportDataStore.reportData.salesToday)
  const salesGrowthLastDay = computed(()=>reportDataStore.reportData.salesGrowthLastDay)
  const salesGrowthLastMonth = computed(()=>reportDataStore.reportData.salesGrowthLastMonth)
  const salesLastDay = computed(()=> reportDataStore.reportData.salesLastDay)
</script>

<style lang="scss" scoped>
.compare {
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: space-around;
  >div {
    display: flex;
    align-items: center;
  }
}
</style>
